using System;
using System.Xml.Serialization;

namespace Opo.Perspective.Core
{
    /// <summary>
    /// Represents a phone number
    /// </summary>
    [XmlRoot("phoneNumber")]
    public class PhoneNumber : IPhoneNumber
    {
        /// <summary>
        /// Gets or sets the type (e.g. "Home", "Work",...)
        /// </summary>
        /// <value>The type.</value>
        [XmlAttribute("type")]
        public string Type { get; set; }
        /// <summary>
        /// Gets or sets the phone number.
        /// </summary>
        /// <value>The phone number.</value>
        [XmlText]
        public string Number { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="PhoneNumber"/> class.
        /// </summary>
        public PhoneNumber() { }
        /// <summary>
        /// Initializes a new instance of the <see cref="PhoneNumber"/> class.
        /// </summary>
        /// <param name="phoneNumber">The phone number.</param>
        public PhoneNumber(string phoneNumber) : this(phoneNumber, "") { }
        /// <summary>
        /// Initializes a new instance of the <see cref="PhoneNumber"/> class.
        /// </summary>
        /// <param name="phoneNumber">The phone number.</param>
        /// <param name="type">The type.</param>
        public PhoneNumber(string phoneNumber, string type)
        {
            Number = phoneNumber;
            Type = type;
        }

        /// <summary>
        /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:Opo.Perspective.Core.PhoneNumber"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.String"/> that represents the current <see cref="T:Opo.Perspective.Core.PhoneNumber"/>.
        /// </returns>
        public override string ToString()
        {
            return String.Format("{0} ({1})", Number, Type);
        }
    }
}
